/**
 * Copyright (c) 2010, QinJian
 * All rights reserved.
 */
package com.q.course.entity.category;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.validator.constraints.NotBlank;

import com.q.course.entity.user.BaseEntity;

/**
 * @author 覃健,Email:j411@qq.com
 *
 */
@Entity
@Table( name = "q_category" )
public class Category extends BaseEntity {

	@NotBlank
	private String name;
	private Long type;//1:课程。2：快捷时间。6：地点。
	private Integer classHour=0;
	private String color;
	private String textColor;
	private Long categoryId;
	private Category category;
	private Date startTime;
	private Date endTime;
	
	private Boolean isParent = false;
	
	@Transient
	public Boolean getIsParent() {
		return isParent;
	}
	public void setIsParent(Boolean isParent) {
		this.isParent = isParent;
	}
	@Column( name="category_id" )
	public Long getCategoryId() {
		return categoryId;
	}
	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}
	@ManyToOne
	@JoinColumn( name="category_id" , insertable = false , updatable = false )
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
		if( category!=null ){
			this.category.setIsParent(true);
		}
	}
	public String getColor() {
		return color;
	}
	public void setColor(String color) {
		this.color = color;
		setTextColor( PlaceColor.cMap.get(color) );
	}
	public Integer getClassHour() {
		return classHour;
	}
	public void setClassHour(Integer classHour) {
		this.classHour = classHour;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Long getType() {
		return type;
	}
	public void setType(Long type) {
		this.type = type;
	}
	public Date getStartTime() {
		return startTime;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	public String getTextColor() {
		return textColor;
	}
	public void setTextColor(String textColor) {
		this.textColor = textColor;
	}
	
}
